import React from 'react';
import {WeaSearchGroup, WeaFormItem, WeaSelect} from 'ecCom';
import {WeaLocaleProvider} from 'ecCom';
const getLabel = WeaLocaleProvider.getLabel;
import EType from './base/EType';
import ETitle from './base/ETitle';

// 新建流程
export default class Content_addwf extends React.Component {
    state = {
        eShowLayout4AddWf: this.props.eShowLayout4AddWf.selected
    };

    render() {
        const {eShowLayout4AddWf} = this.state;

        let EShowLayout4AddWf = <div></div>;
        if (this.props.eShareLevel == '2') {
            EShowLayout4AddWf = (
                <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@a368xi`} label={getLabel(82134, '显示布局')} labelCol={{span: 6}} wrapperCol={{span: 16}}>
                    <WeaSelect ecId={`${this && this.props && this.props.ecId || ''}_WeaSelect@42dymn`}
                        options={
                            this.props.eShowLayout4AddWf.options.map((item) => {
                                return {key: item.key, selected: false, showname: item.value};
                            })
                        }
                        value={eShowLayout4AddWf}
                        style={{width: '200px'}}
                        onChange={value => {
                            this.setState({eShowLayout4AddWf: value});
                        }}
                    />
                </WeaFormItem>
            );
        }

        return (
            <div>
                <WeaSearchGroup ecId={`${this && this.props && this.props.ecId || ''}_WeaSearchGroup@m03gw2`} title={getLabel(81711, '基本信息')} needTigger={true} showGroup={true}>
                    <EType ecId={`${this && this.props && this.props.ecId || ''}_EType@2vfx49`} ref="eType" value={this.props.eBaseName}/>
                    {this.props.eShareLevel == '2' ? <ETitle ecId={`${this && this.props && this.props.ecId || ''}_ETitle@bdj4hd`} ref="eTitle" eid={this.props.eid} value={this.props.eTitle} {...this.props}/> : ''}
                    {EShowLayout4AddWf}
                </WeaSearchGroup>
            </div>
        );
    }

    getSaveValues() {
        return {
            eContentTitle: this.refs['eTitle'] ? this.refs['eTitle'].getSaveValues() : this.props.eTitle,
            eContentTabWidth: {tabwidth: this.props.etabwidth, methodvalue: this.props.methodvalue},
            eContenteTabStyle: {tabstyle: this.props.tabstyle, tabvalue: this.props.tabvalue, tabname: this.props.tabname},
            eContentShowLayout: this.state.eShowLayout4AddWf,
        };
    }
}